Update toml-rs
authorAlex Crichton <alex@alexcrichton.com>
Wed, 16 Jul 2014 15:08:55 +0000 (08:08 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 16 Jul 2014 15:08:55 +0000 (08:08 -0700)
TOML recently grew multiline string literals as well as literal strings with no
escaping, which can be used instead of the hokey escape_path() function.

libs/toml-rs
src/cargo/util/config.rs
tests/support/mod.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_git_deps.rs
tests/test_cargo_compile_path_deps.rs

index a0f1ea65fc80379f0c6c095d92fad840004aaa56..3a7ec7f4c4716d2967aedab2ef3d051c9cfc2041 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a0f1ea65fc80379f0c6c095d92fad840004aaa56
+Subproject commit 3a7ec7f4c4716d2967aedab2ef3d051c9cfc2041
index a8e71d3e34b4a20a3737c7d46257ebcb627a818f..ead9fde130a639cd8ae2a4e41855428f907941eb 100644 (file)
@@ -309,7 +309,7 @@ fn extract_config(mut file: io::fs::File, key: &str) -> CargoResult<ConfigValue>
     let mut toml = try!(cargo_toml::parse(contents.as_slice(),
                                           file.path().filename_display()
                                               .to_string().as_slice()));
-    let val = try!(toml.pop_equiv(&key).require(|| internal("")));
+    let val = try!(toml.pop(&key.to_string()).require(|| internal("")));
 
     ConfigValue::from_toml(file.path(), val)
 }
index fd99e08d8ceb18e7c5ced11ca43425b2eaf38f8f..30246736224ae2bbf6a2781a5ba3ba97b7c69b68 100644 (file)
@@ -401,10 +401,6 @@ impl<T> Tap for T {
     }
 }
 
-pub fn escape_path(p: &Path) -> String {
-    p.display().to_string().as_slice().replace("\\", "\\\\")
-}
-
 pub fn basic_bin_manifest(name: &str) -> String {
     format!(r#"
         [package]
index c722957ae4b538e8299997083fc2b3aad2ed326a..db114ac840ababc951848eaa1530527a3aaca87c 100644 (file)
@@ -3,7 +3,7 @@ use std::os;
 use std::path;
 use std::str;
 
-use support::{ResultTest, project, execs, main_file, escape_path, basic_bin_manifest};
+use support::{ResultTest, project, execs, main_file, basic_bin_manifest};
 use support::{COMPILING, RUNNING};
 use hamcrest::{assert_that, existing_file};
 use cargo;
@@ -146,8 +146,8 @@ test!(cargo_compile_with_warnings_in_a_dep_package {
 
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}"]
-        "#, escape_path(&bar)).as_slice())
+            paths = ['{}']
+        "#, bar.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -209,8 +209,8 @@ test!(cargo_compile_with_nested_deps_inferred {
 
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}", "{}"]
-        "#, escape_path(&bar), escape_path(&baz)).as_slice())
+            paths = ['{}', '{}']
+        "#, bar.display(), baz.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -277,8 +277,8 @@ test!(cargo_compile_with_nested_deps_correct_bin {
 
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}", "{}"]
-        "#, escape_path(&bar), escape_path(&baz)).as_slice())
+            paths = ['{}', '{}']
+        "#, bar.display(), baz.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -345,8 +345,8 @@ test!(cargo_compile_with_nested_deps_shorthand {
 
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}", "{}"]
-        "#, escape_path(&bar), escape_path(&baz)).as_slice())
+            paths = ['{}', '{}']
+        "#, bar.display(), baz.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -421,8 +421,8 @@ test!(cargo_compile_with_nested_deps_longhand {
 
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}", "{}"]
-        "#, escape_path(&bar), escape_path(&baz)).as_slice())
+            paths = ['{}', '{}']
+        "#, bar.display(), baz.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -517,10 +517,10 @@ test!(custom_build {
             name = "foo"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = "{}"
+            build = '{}'
 
             [[bin]] name = "foo"
-        "#, escape_path(&build.bin("foo"))))
+        "#, build.bin("foo").display()))
         .file("src/foo.rs", r#"
             fn main() {}
         "#);
@@ -581,10 +581,10 @@ test!(custom_multiple_build {
             name = "foo"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = [ "{} hello world", "{} cargo" ]
+            build = [ '{} hello world', '{} cargo' ]
 
             [[bin]] name = "foo"
-        "#, escape_path(&build1.bin("foo")), escape_path(&build2.bin("bar"))))
+        "#, build1.bin("foo").display(), build2.bin("bar").display()))
         .file("src/foo.rs", r#"
             fn main() {}
         "#);
@@ -622,11 +622,11 @@ test!(custom_build_failure {
             name = "foo"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = "{}"
+            build = '{}'
 
             [[bin]]
             name = "foo"
-        "#, escape_path(&build.bin("foo"))))
+        "#, build.bin("foo").display()))
         .file("src/foo.rs", r#"
             fn main() {}
         "#);
@@ -683,11 +683,11 @@ test!(custom_second_build_failure {
             name = "foo"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = [ "{}", "{}" ]
+            build = [ '{}', '{}' ]
 
             [[bin]]
             name = "foo"
-        "#, escape_path(&build1.bin("foo")), escape_path(&build2.bin("bar"))))
+        "#, build1.bin("foo").display(), build2.bin("bar").display()))
         .file("src/foo.rs", r#"
             fn main() {}
         "#);
@@ -717,12 +717,12 @@ test!(custom_build_env_vars {
         .file("src/foo.rs", format!(r#"
             use std::os;
             fn main() {{
-                assert_eq!(os::getenv("OUT_DIR").unwrap(), "{}".to_string());
-                assert_eq!(os::getenv("DEPS_DIR").unwrap(), "{}".to_string());
+                assert_eq!(os::getenv("OUT_DIR").unwrap(), r"{}".to_string());
+                assert_eq!(os::getenv("DEPS_DIR").unwrap(), r"{}".to_string());
             }}
         "#,
-        escape_path(&p.root().join("target")),
-        escape_path(&p.root().join("target").join("deps"))));
+        p.root().join("target").display(),
+        p.root().join("target").join("deps").display()));
     assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
 
 
@@ -733,11 +733,11 @@ test!(custom_build_env_vars {
             name = "foo"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = "{}"
+            build = '{}'
 
             [[bin]]
             name = "foo"
-        "#, escape_path(&build.bin("foo"))))
+        "#, build.bin("foo").display()))
         .file("src/foo.rs", r#"
             fn main() {}
         "#);
@@ -762,19 +762,19 @@ test!(custom_build_in_dependency {
         .file("src/foo.rs", format!(r#"
             use std::os;
             fn main() {{
-                assert_eq!(os::getenv("OUT_DIR").unwrap(), "{}".to_string());
-                assert_eq!(os::getenv("DEPS_DIR").unwrap(), "{}".to_string());
+                assert_eq!(os::getenv("OUT_DIR").unwrap(), r"{}".to_string());
+                assert_eq!(os::getenv("DEPS_DIR").unwrap(), r"{}".to_string());
             }}
         "#,
-        escape_path(&p.root().join("target/deps")),
-        escape_path(&p.root().join("target/deps"))));
+        p.root().join("target/deps").display(),
+        p.root().join("target/deps").display()));
     assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
 
 
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}"]
-        "#, escape_path(&bar)).as_slice())
+            paths = ['{}']
+        "#, bar.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -797,8 +797,8 @@ test!(custom_build_in_dependency {
             name = "bar"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = "{}"
-        "#, escape_path(&build.bin("foo"))))
+            build = '{}'
+        "#, build.bin("foo").display()))
         .file("bar/src/lib.rs", r#"
             pub fn bar() {}
         "#);
index 01a39aa081d66a9b15a459a2212c5cba4ce46342..b0ae8c26756286de54b4cc51d3d58ce1a85688d1 100644 (file)
@@ -1,7 +1,7 @@
 use std::io::File;
 
 use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths};
-use support::{escape_path, cargo_dir};
+use support::{cargo_dir};
 use support::{COMPILING, FRESH, UPDATING};
 use hamcrest::{assert_that,existing_file};
 use cargo;
@@ -71,12 +71,12 @@ test!(cargo_compile_simple_git_dep {
 
             [dependencies.dep1]
 
-            git = "file:{}"
+            git = 'file:{}'
 
             [[bin]]
 
             name = "foo"
-        "#, escape_path(&git_project.root())))
+        "#, git_project.root().display()))
         .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
 
     let root = project.root();
@@ -134,13 +134,13 @@ test!(cargo_compile_git_dep_branch {
 
             [dependencies.dep1]
 
-            git = "file:{}"
+            git = 'file:{}'
             branch = "branchy"
 
             [[bin]]
 
             name = "foo"
-        "#, escape_path(&git_project.root())))
+        "#, git_project.root().display()))
         .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
 
     let root = project.root();
@@ -199,13 +199,13 @@ test!(cargo_compile_git_dep_tag {
 
             [dependencies.dep1]
 
-            git = "file:{}"
+            git = 'file:{}'
             tag = "v0.1.0"
 
             [[bin]]
 
             name = "foo"
-        "#, escape_path(&git_project.root())))
+        "#, git_project.root().display()))
         .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
 
     let root = project.root();
@@ -283,12 +283,12 @@ test!(cargo_compile_with_nested_paths {
             [dependencies.dep1]
 
             version = "0.5.0"
-            git = "file:{}"
+            git = 'file:{}'
 
             [[bin]]
 
             name = "parent"
-        "#, escape_path(&git_project.root())))
+        "#, git_project.root().display()))
         .file("src/parent.rs",
               main_file(r#""{}", dep1::hello()"#, ["dep1"]).as_slice());
 
@@ -351,17 +351,17 @@ test!(cargo_compile_with_meta_package {
             [dependencies.dep1]
 
             version = "0.5.0"
-            git = "file:{}"
+            git = 'file:{}'
 
             [dependencies.dep2]
 
             version = "0.5.0"
-            git = "file:{}"
+            git = 'file:{}'
 
             [[bin]]
 
             name = "parent"
-        "#, escape_path(&git_project.root()), escape_path(&git_project.root())))
+        "#, git_project.root().display(), git_project.root().display()))
         .file("src/parent.rs",
               main_file(r#""{} {}", dep1::hello(), dep2::hello()"#, ["dep1", "dep2"]).as_slice());
 
@@ -438,12 +438,12 @@ test!(two_revs_same_deps {
             authors = []
 
             [dependencies.bar]
-            git = "file:{}"
+            git = 'file:{}'
             rev = "{}"
 
             [dependencies.baz]
             path = "../baz"
-        "#, escape_path(&bar.root()), rev1.as_slice().trim()).as_slice())
+        "#, bar.root().display(), rev1.as_slice().trim()).as_slice())
         .file("src/main.rs", r#"
             extern crate bar;
             extern crate baz;
@@ -462,9 +462,9 @@ test!(two_revs_same_deps {
             authors = []
 
             [dependencies.bar]
-            git = "file:{}"
+            git = 'file:{}'
             rev = "{}"
-        "#, escape_path(&bar.root()), rev2.as_slice().trim()).as_slice())
+        "#, bar.root().display(), rev2.as_slice().trim()).as_slice())
         .file("src/lib.rs", r#"
             extern crate bar;
             pub fn baz() -> int { bar::bar() }
@@ -508,12 +508,12 @@ test!(recompilation {
             [dependencies.bar]
 
             version = "0.5.0"
-            git = "file:{}"
+            git = 'file:{}'
 
             [[bin]]
 
             name = "foo"
-        "#, escape_path(&git_project.root())))
+        "#, git_project.root().display()))
         .file("src/foo.rs",
               main_file(r#""{}", bar::bar()"#, ["bar"]).as_slice());
 
index 3b031301c6d22ff6d03ae50aacfadcf75ad24bd1..d721ec6444aeef3a39843f8495d38c90fa51d12a 100644 (file)
@@ -1,7 +1,7 @@
 use std::io::File;
 use std::io::timer;
 
-use support::{ResultTest, project, execs, main_file, escape_path, cargo_dir};
+use support::{ResultTest, project, execs, main_file, cargo_dir};
 use support::{COMPILING, FRESH};
 use hamcrest::{assert_that, existing_file};
 use cargo;
@@ -208,8 +208,8 @@ test!(no_rebuild_dependency {
     let bar = p.root().join("bar");
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}"]
-        "#, escape_path(&bar)).as_slice())
+            paths = ['{}']
+        "#, bar.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -263,8 +263,8 @@ test!(deep_dependencies_trigger_rebuild {
     let baz = p.root().join("baz");
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}", "{}"]
-        "#, escape_path(&bar), escape_path(&baz)).as_slice())
+            paths = ['{}', '{}']
+        "#, bar.display(), baz.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]
 
@@ -361,8 +361,8 @@ test!(no_rebuild_two_deps {
     let baz = p.root().join("baz");
     p = p
         .file(".cargo/config", format!(r#"
-            paths = ["{}", "{}"]
-        "#, escape_path(&bar), escape_path(&baz)).as_slice())
+            paths = ['{}', '{}']
+        "#, bar.display(), baz.display()).as_slice())
         .file("Cargo.toml", r#"
             [project]